

const Router = require('koa-router')

const { auth, verifyAdmin } = require('../middleware/auth.middleware')
const { create, update, query, statusQuery, adminQuery, auditQueryAll, audit, auditStatusQueryAll, remove } = require('../controller/expense.controller')
const { validatort } = require('../middleware/validator.middlewear')
const { formatError } = require('../constant/error.type')
const router = new Router({ prefix: '/expense' })


router.post('/', auth, validatort({ expType: 'number', money: 'number', remark: 'string' }, formatError), create)

router.put('/:id', auth, validatort({ expType: 'number', money: 'number', remark: 'string' }, formatError), update)

router.get('/', auth, query)

router.get('/:status', auth, statusQuery)

router.get('/admin/all', auth, verifyAdmin, adminQuery)

router.get('/admin/audit', auth, verifyAdmin, auditQueryAll)

router.get('/audit/:status', auth, verifyAdmin, auditStatusQueryAll)

router.put('/audit/:id/:status', auth, verifyAdmin, audit)

router.delete('/:id', auth, remove)


module.exports = router